﻿/**
 * Created in 2012-3-2.
 */
package kit4j.tests.jdk.lang;

/**
 * 
 * @author 鍚存敛
 * 
 */
public class TestCatchException {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		System.out.println(test());
	}

	static int test() throws Exception {
		Exception finalException = null;
		
		for (int i = 0; i < 10; ++i) {
			try {
				return check(i);
//				return result;
			} catch (Exception e) {
				finalException = e;
			}
		}

		throw finalException;
	}

	static int check(int n) throws Exception {
		if (n != 15) {
			throw new Exception("n!=15 and n=" + n);
		} else {
			return n;
		}
	}

}
